package com.szp.drug.util;

import javax.servlet.http.HttpServletRequest;

/**
 * 工具类
 * @author SuZePing
 * @create 2021-01-12 8:18
 * @E-mail suzeping10@126.com
 */
public class DrugUtil {

	/**
	 * 判断当前请求是否是ajax请求
	 * @param request
	 * @return
	 */
	public static boolean judgeRequestType(HttpServletRequest request){
		String acceptHeader = request.getHeader("Accept");
		String xRequestedHeader = request.getHeader("X-Requested-With");
		return acceptHeader != null && acceptHeader.contains("application/json")
				||
				xRequestedHeader != null && xRequestedHeader.equals("XMLHttpRequest");
	}

}
